import request from '@/utils/request'
import type { SearchParams,SearcherResults } from './interface'
enum Api {
    searcherResultApi = '/xhr/search/search.json',
}


/**
 * 获取查询结果
 * @keyword 关键词
 * @page 页码
 * @size 条数
 * @sortType 排序类型
 * @descSorted 升序/降序
 * @categoryId 一级分类id
 * @floorPrice 最低价
 * @upperPrice 最高价
 * @returns SearcherResults
 */
export const reqSearcher = (searchQuery: SearchParams) => {
    return request.get<SearcherResults,SearcherResults>(Api.searcherResultApi, {
        params: {
            __timestamp: window.Date.now(),
            keyword: searchQuery.keyword,
            page: searchQuery.page,
            size: searchQuery.size,
            sortType: searchQuery.sortType,
            descSorted: searchQuery.descSorted,
            categoryId: searchQuery.categoryId,
            matchType: searchQuery.matchType,
            floorPrice: searchQuery.floorPrice,
            upperPrice: searchQuery.upperPrice,
            stillSearch: searchQuery.stillSearch,
            searchWordSource: searchQuery.searchWordSource,
        }
    })
}